﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pgAudCum.aspx.cs" Inherits="EGuayas.Web.Auditoria.admin.Global.pgAudCum" %>
<%@ Register src="~/Auditoria/admin/Global/wucPeriodicidad.ascx" tagPrefix="uc1" tagName="wucPeriodicidad" %>


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="~/Resources/css/Style.css" rel="stylesheet" />
    <!-- Load Ext JS -->
    <script src="../../../Resources/js/Global.js"></script>
    <script>
        //Bug: TypeError: Cannot call method 'setMinValue' of undefined 
        //Modificado para buscar elementos,contenidos en varios paneles
        //Restrinción los id de los elementos no debe contener caracter _
        Ext.apply(Ext.form.VTypes, {
            daterange: function (val, field) {
                var preName = "";
                var date = field.parseDate(val);
                var indexName = field.id.lastIndexOf("_");
                if (indexName > 0) {
                    preName = field.id.substring(0, indexName + 1);
                }
                if (field.startDateField && (!date || (!field.dateRangeMax || (date.getTime() !== field.dateRangeMax.getTime())))) {
                    var start = Ext.getCmp(preName + field.startDateField);

                    if (start) {
                        start.setMaxValue(date);
                        field.dateRangeMax = date;
                        start.validate();
                    }
                } else if (field.endDateField && (!date || (!field.dateRangeMin || (date.getTime() !== field.dateRangeMin.getTime())))) {
                    var end = Ext.getCmp(preName + field.endDateField);

                    if (end) {
                        end.setMinValue(date);
                        field.dateRangeMin = date;
                        end.validate();
                    }
                }

                /*
                 * Always return true since we're only using this vtype to set the
                 * min/max allowed values (these are tested for after the vtype test)
                 */
                return true;
            }
        });
        
    </script>
</head>
<body>
    <form runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server"></ext:ResourceManager>
        <uc1:wucPeriodicidad runat="server" id="wucPeriodicidad" Name="wucPeriodicidad" />
            
        <%-- 
            <ext:Viewport ID="vipContenedor" runat="server" Layout="BorderLayout">
            <Items>
         --%>
               <ext:Panel ID="panContenedorAuditoria" runat="server" Padding="0" Layout="card">
                   <Items>
                                              
                           <ext:FormPanel 
                           ID="frmAuditoria" 
                           runat="server" 
                           Border="false"
                           ButtonAlign="Center"
                           Title="Configuraciones de Auditoria Cumplimiento"
                       
                           BodyStyle="background-color:transparent;"
                           BodyPadding="10"
                           Layout="Form">
                           <Items>
                                 <%-- Hidden almacena Id de Auditoria de Cumplimiento  --%>
                                <ext:Hidden Text="" ID="hddIdAudCum" runat="server"></ext:Hidden>
                                <ext:NumberField ID="txtPeriod" runat="server" Name ="Periodo"  FieldLabel ="Periodo"    MaxLength="4"  MinLength="4" AllowBlank="false"/>
                                <ext:DateField 
                                        ID="dtFechaInicio" 
                                        runat="server" 
                                        MsgTarget="Side" 
                                        AllowBlank="false"
                                        FieldLabel="Fecha Inicio" 
                                        Name="FechaInicio"
                                        Vtype="daterange" 
                                        EndDateField="dtFechaFin"
                                        EnableKeyEvents="true"
                                       
                                        />
                                     <ext:DateField 
                                        ID="dtFechaFin" 
                                        runat="server" 
                                        MsgTarget="Side" 
                                        AllowBlank="false"
                                        FieldLabel="Fecha Fin"
                                        Name="FechaFin" 
                                        Vtype="daterange"
                                        StartDateField="dfFechaInicio"
                                        EnableKeyEvents="true" 
                                        />                                       
                           </Items>
                           <Listeners>
                                    <ValidityChange Handler="#{btnSave}.setDisabled(!valid);" />
                           </Listeners>
                           <Buttons>
                              <ext:Button ID="btnSave" runat="server" Text="Aceptar" Disabled="true">
                                <DirectEvents>
                                    <Click OnEvent="btnSave_Click">
                                        <ExtraParams>
                                            <ext:Parameter Name="prmValues" Value="Ext.encode(App.frmAuditoria.getForm().getValues())" Mode="Raw" />
                                        </ExtraParams>
                                        <EventMask ShowMask="True"></EventMask>
                                    </Click>
                                </DirectEvents>
                              </ext:Button>
                               <%-- 
                               <ext:Button ID="btnSiguiente" runat="server" Text="Siguiente">
                                   <Listeners>
                                       <Click Handler="pgFn.clickNext(1);"></Click>
                                   </Listeners>
                               </ext:Button>
                               --%>
                           </Buttons>  
                         </ext:FormPanel>
                        <%-- 
                             <ext:FormPanel ID="frmResultados" runat="server"  Title="Fases"  Icon="TableRefresh"   Layout="Fit" ButtonAlign="Center">
                                <Items>
                                     <ext:UserControlLoader ID="uc_fases_002"  UserControlID="wuc_fases_002"  runat="server" Path="~/Auditoria/admin/Cumplimiento/wucFases.ascx" OnComponentAdded="OnLoadFasesAdded"/>                                                     
                                </Items>
                                 <Buttons>
                                       <ext:Button ID="btnAnterior" runat="server" Text="Anterior">
                                       <Listeners>
                                           <Click Handler="pgFn.clickNext(0);"></Click>
                                       </Listeners>
                                     </ext:Button>
                                 </Buttons>
                            </ext:FormPanel>
                        --%>
                     </Items>
                 </ext:Panel>
         <%--     
        </Items>
        </ext:Viewport>
        --%>
    </form>
     <ext:XScript ID="XScript1" runat="server">
        <script type="text/javascript">
            var pgFn = new Object();
            pgFn.clickNext = function (i) {
                try 
                {                  
                  #{panContenedorAuditoria}.getLayout().setActiveItem(i);
                } catch (jsbug) {
                    AppGlobalJs.showBug("pgFn.setReadOnly :" + jsbug)
                }
            }
            pgFn.setReadOnly = function () {
                try 
                {                  
                    AppGlobalJs.setReadOnly(#{frmAuditoria},true);                
                } catch (jsbug) {
                    AppGlobalJs.showBug("pgFn.setReadOnly :" + jsbug)
                }
            }
        </script>
    </ext:XScript>
</body>
</html>
